//package com.qike.huadongexcel.config;
//
//import org.springframework.context.annotation.Configuration;
//import org.springframework.http.HttpHeaders;
//import org.springframework.util.StringUtils;
//import org.springframework.web.servlet.HandlerInterceptor;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
///**
// * @Author: Eric.zhou
// * @Date: 2019/10/10 10:37
// */
//@Configuration
//public class CrossInterceptor implements HandlerInterceptor {
//    private String accessControlAllowOrigin;
//
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
//      String curOrigin = request.getHeader("Origin");
//        if (!StringUtils.isEmpty(curOrigin)) {
//            String[] allowUrls = accessControlAllowOrigin.split(",");
//            for (String origin : allowUrls) {
//                if (origin.equals(curOrigin)) {
//                    response.addHeader("Access-Control-Allow-Origin", origin);
//                }
//            }
//        }
//        response.addHeader("Access-Control-Allow-Credentials", "true");
//        response.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE");
//        response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Connection, User-Agent, Cookie, Authorization");
//        return true;
//    }
//    public void setAccessControlAllowOrigin(String accessControlAllowOrigin) {
//        this.accessControlAllowOrigin = accessControlAllowOrigin;
//    }
//}
